﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SmartMeterParamFrame.Model.DIValueConverters
{

    /// <summary>
    /// 转换形如 NNNN的di数据，
    /// 包括 公共假日数据
    /// </summary>
    class Converter_2BCD : IDIDataConverter
    {
        public bool CanConverter(string di)
        {
            if (di.Equals("04000205"))
                return true;
            return false;
        }

        public string ConvertToUI(string di, string lowValue)
        {
            int firstPositiveIndex = lowValue.IndexOfAny(DIValueConverter.NUMBER_POSITIVE);
            string newValue = lowValue.Substring(firstPositiveIndex, lowValue.Length - firstPositiveIndex);
            return newValue;
        }

        public string ConvertToLow(string di, string uiValue)
        {
            string newValue = uiValue.PadLeft(4, '0');
            return newValue;
        }

        public bool ValidateValue(string di, string value)
        {
            throw new NotImplementedException();
        }
    }
}
